<?php

namespace app\admin\controller;

use think\Controller;
use Util\Sysdb;
use think\facade\Session;
use app\admin\model\Userlog as log;

class BaseAdmin extends Controller
{
    public function __construct(){

        //检测用户是否登录
        parent::__construct();
        $this->_admin = session('admin');

        //未登录的用户不允许访问
        if(!$this->_admin){
            header('location:login');
            exit;
        }else{
            //$this->loginlog();
        }
    }

    public function loginlog(){
        //增加用户登录日志
        $ip = $_SERVER["REMOTE_ADDR"];
        $userlog = new log();
        $userid = Session::get('admin.id');
        $nickname = Session::get('admin.username');
        $userlog->addUserlog($userid,$nickname,$ip);
    }
    
}